package com.four.reimbursemanage.controller;

import com.four.reimbursemanage.common.bean.ResponseData;
import com.four.reimbursemanage.common.controller.BaseController;
import com.four.reimbursemanage.entity.CondolenceApply;
import com.four.reimbursemanage.entity.Dailyapply;
import com.four.reimbursemanage.entity.Payapply;
import com.four.reimbursemanage.service.CondolenceApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@CrossOrigin
@RequestMapping("/condoleApply")
public class CondolenceApplyController extends BaseController {
    @Autowired
    private CondolenceApplyService condolenceApplyService;
    /**
     * 查询支付申请列表
     */
    @GetMapping("/condoleList")
    public ResponseData<Object> getCondoleList(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "applyDepartment",required = false) String applyDepartment,
            @RequestParam(value = "payee",required = false) String payee,
            @RequestParam(value = "state",required = false) Integer state
    ){
        return returnObject(condolenceApplyService.getOnrePage(pageNum, pageSize, applyDepartment,  payee, state));
    }

    /**
     * 查询支付申请列表
     */
    @GetMapping("/selectByNum")
    public ResponseData<Object> getCondoleListUser(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "applyDepartment",required = false) String applyDepartment,
            @RequestParam(value = "payee",required = false) String payee,
            @RequestParam(value = "state",required = false) Integer state,
            @RequestParam(value = "number",required = false) String number
    ){
        return returnObject(condolenceApplyService.getOnrePageUser(pageNum, pageSize, applyDepartment,  payee, state, number));
    }

    /**
     * 新增慰问金申请
     */

    @PostMapping("/add")
    public ResponseData<Boolean> add(CondolenceApply condolenceApply)
    {
        return returnBoolean(condolenceApplyService.insertComdolenceapply(condolenceApply));
    }

    /**
     * 修改慰问金申请
     */

    @PutMapping("/update")
    public ResponseData<Boolean> edit(@RequestBody CondolenceApply condolenceApply)
    {
        return returnBoolean(condolenceApplyService.updateCondolenceApply(condolenceApply));
    }

    //更新状态可撤销
    @PutMapping("/updateC")
    public  ResponseData<Boolean> updateS(@RequestBody  CondolenceApply condolenceApply){
        return returnBoolean(condolenceApplyService.updateC(condolenceApply));
    }
}
